package com.otp.model.test.template;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "attributes")
public class Attribute extends BaseObject implements java.io.Serializable{

	private static final long serialVersionUID = -4569379924191759233L;
	private Long objectId;
	private String name;
	private String description;
	private Integer order; 

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "object_id", unique = true, nullable = false)
	public Long getObjectId() {
		return objectId;
	}	
	public void setObjectId(Long objectId) {
		this.objectId = objectId;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(name="order_in_set")
	public Integer getOrder(){
		return order;
	}
	public void setOrder(Integer order){
		this.order=order;
	}
	
	@Override
	public int hashCode() {
		return (objectId != null ? objectId.hashCode() : 0);
	}
	
	@Override
	public boolean equals(Object o) {
		if (this == o) {
            return true;
        }
        if (!(o instanceof Attribute)) {
            return false;
        }

        final Attribute att = (Attribute) o;

        return objectId.equals(att.getObjectId());
	}
	
	@Override
	public String toString() {
        ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
        .append("objectId", this.objectId)
        .append("name", this.name)
        .append("description", this.description);
        return sb.toString();
	}
}
